package com.qianhai.mytinkerdemo;

import android.os.Environment;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.tencent.tinker.lib.tinker.TinkerInstaller;

import java.io.File;
import java.util.logging.Logger;

import static android.os.Environment.getExternalStorageDirectory;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        File dir=Environment.getExternalStorageDirectory();
        Log.d("----","----dir="+dir);
        final String appPath=dir.getPath()+"/TinkerDemo";
        File file = new File(appPath);
        if(!file.exists()){
            file.mkdir();
        }
        findViewById(R.id.btn_load).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String path=appPath+"/patch_signed_7zip.zip";
                Log.d("----","---path="+path);
                if(new File(path).exists()){
                    TinkerInstaller.onReceiveUpgradePatch(getApplication(), path);
                }else{
                    Toast.makeText(getApplicationContext(),"找不到补丁",Toast.LENGTH_LONG).show();
                }

            }
        });
    }
}
